package com.dgshanger.sanhxiaofeisc.ui.person.purse

import android.annotation.SuppressLint
import com.dgshanger.sanhxiaofeisc.R
import com.dgshanger.sanhxiaofeisc.common.Constants
import com.dgshanger.sanhxiaofeisc.entity.BillEntity
import com.dgshanger.sanhxiaofeisc.mvp.contract.BillDetailContract
import com.dgshanger.sanhxiaofeisc.mvp.presenter.BillDetailPresenter
import com.dgshanger.sanhxiaofeisc.ui.home.utils.ImageLoader
import com.xx.baseuilibrary.mvp.BaseMvpActivity
import kotlinx.android.synthetic.main.activity_bill_detail.*


/**
 * BillDetailActivity
 * 沉迷学习不能自拔
 * Describe：账单详情页面
 * Created by 雷小星🍀 on 2018/4/18 11:05.
 */
class BillDetailActivity : BaseMvpActivity<BillDetailContract.Model, BillDetailContract.View, BillDetailPresenter>(), BillDetailContract.View {

    override fun getLogId(): String = intent.getStringExtra(Constants.KEY_INTENT_LOG_ID)

    @SuppressLint("SetTextI18n")
    override fun setDetails(billEntity: BillEntity?) {
        with(billEntity!!) {
            tv_display_title.text = display_title
            tv_wallet_money.text = "${if ("1".equals(wallet_status)) "+" else "-"}$wallet_money"
            tv_integral_money.text = "${if ("1".equals(integral_stastus)) "+" else "-"}$integral_money"
            tv_pay_order_sn.text = pay_order_sn
            tv_created_at.text = created_at
            tv_bill_remark.text = bill_remark
            ImageLoader.loadAvatar(mContext, civ_icon, bill_logo)
            //订单类型
            tv_bill_type.text = bill_type.run {
                when (bill_type) {
                    "1" -> "商家支付"
                    "2" -> "会员分佣"
                    "3" -> "会员购买"
                    "4" -> "员代付购买"
                    else -> ""
                }
            }
        }
    }

    override fun createPresenter(): BillDetailPresenter = BillDetailPresenter()

    override fun getActivityLayoutId(): Int = R.layout.activity_bill_detail

    override fun initData() {
        getPresenter().loadDetail()
    }

    override fun initEvent() {

    }
}